package reit.ass3;


/**
 * The Class Locatable.
 */
class Locatable implements LocatableInterface{

	/** The location. */
	private Location location;

	/**
	 * Instantiates a new locatable.
	 */
	public Locatable(){
		location = new Location();
	};

	/**
	 * Instantiates a new locatable.
	 *
	 * @param x the x
	 * @param y the y
	 */
	public Locatable(final double x, final double y){
		location = new Location(x,y);
	}; 

	/* (non-Javadoc)
	 * @see ass3.LocatableInterface#getLocation()
	 */
	@Override
	public Location getLocation() {
		return location;
	};

	/* (non-Javadoc)
	 * @see ass3.LocatableInterface#getDistance(ass3.Location)
	 */
	@Override
	public Double getDistance(final Location loc) {
		return Math.sqrt(Math.pow(Math.abs((this.location.getX() - loc.getX())) ,2) +  Math.pow(Math.abs((this.location.getY() - loc.getY())) ,2));
	};

	/**
	 * Gets the distance.
	 *
	 * @param loc1 the loc1
	 * @param loc2 the loc2
	 * @return the distance
	 */
	public static Double getDistance(final Location loc1, final Location loc2) {
		return Math.sqrt(Math.pow(Math.abs((loc2.getX() - loc1.getX())) ,2) +  Math.pow(Math.abs((loc2.getY() - loc1.getY())) ,2));
	};
}
